#include <stdio.h>
#include <stdlib.h>

const int MAX_DISTANCE = 100000;
const int MAX_VILLAGES = 100;

/**
 * Retorna o menor valor entre os dois passados como argumento
 *
 * @param i o primeiro valor
 * @param j o segundo valor
 *
 * @return o menor valor entre i e j
 */
int min(int i, int j) {
    return i < j ? i : j;
}

/********************************************************************************
 * Problema da disciplina de Estrutura de Dados e Complexidade de Algoritmos da *
 * Pos Graduacao do Periodo 2011.1                                              *
 *                                                                              *
 * @see https://br.spoj.pl/problems/DENGUE/                                     *
 * @author Elenilson Vieira - 111100371 - elenilson[at]elenilsonvieira.com      *
 * @since 21 de junho de 2011                                                   *
 ********************************************************************************/
int main(int argc, char** argv) {

    int graph[MAX_VILLAGES][MAX_VILLAGES];
    int villagesAmount = 0;
    int testNumber = 1;
    int townToVaccinationPost = 0;
    int i = 0, j = 0, k = 0;

    while (scanf("%d", &villagesAmount) == 1 && villagesAmount != 0) {
        townToVaccinationPost = 0;

        /*** Inicia o array com 0 na diagonal e maior valor nas outras posicoes ***/
        for (i= 0; i < villagesAmount; i++) {
            for (j= 0; j < villagesAmount; j++) {
                if(i != j)
                    graph[i][j] = MAX_DISTANCE;
                else
                    graph[i][j] = 0;
            }
        }

        /*** Ler as ligacoes ***/
        for (i= 0; i < villagesAmount - 1; i++) {
            int x = 0;
            int y = 0;
            scanf("%d %d", &x, &y);

            graph[x - 1][y - 1] = graph[y - 1][x - 1] = 1;
        }

        /*** Aplica o algoritmo de floyd ***/
        for(k = 0; k < villagesAmount; k++)
            for(i = 0; i < villagesAmount; i++)
                for(j = 0; j < villagesAmount; j++)
                    graph[i][j] = min(graph[i][j], graph[i][k]+graph[k][j]);
        
        /*** Ve quem tem a menor distancia ***/
        int maxDistance = MAX_DISTANCE;
        for (i= 0; i < villagesAmount; i++) {
            int maxDistanceI = 0;
            for (j= 0; j < villagesAmount; j++) {
                if(graph[i][j] > maxDistanceI)
                    maxDistanceI = graph[i][j];
            }

            if(maxDistanceI <= maxDistance){
                maxDistance = maxDistanceI;
                townToVaccinationPost = i;
            }
        }

        /*** Faz as impressoes ***/
        printf("Teste %d\n%d\n\n", testNumber++, townToVaccinationPost + 1);
    }

    return (EXIT_SUCCESS);
}

